﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld" %>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/ecommerce">电商管理</a></li>
          <li class="active">逾期课时</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>逾期课时&nbsp;-&nbsp;课时列表</span></h2>
              <div class="pull-right" style="padding-left: 10px">
                <c:choose>
                  <c:when test="${not empty currentPrincipal.site}">
                    <p class="current-branchCode form-control-static">${currentPrincipal.site.name}</p>
                  </c:when>
                  <c:otherwise>
                    <select name="site">
                      <option value="">所有门店</option>
                      <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                        <option value="${site.id}" ${site.id == param.site ? 'selected' : ''}>${site.name}</option>
                      </c:forEach>
                    </select>
                  </c:otherwise>
                </c:choose>
              </div>
              <div class="btn-group pull-right">
                <a href="${ctx.host}/expiry-schedules/export?week=${week}&site=${site}&${queryString}"  class="btn btn-default x-btn btn-shadow btn-shadow-default ">导出Excel</a>
                <a href="${ctx.host}/expiry-schedules/search?week=${week}&site=${site}&${queryString}" data-target="#expire-search" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default">
                  <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询</a>
              </div>
            </div>
          </div>
           <p class="text-center" style="background-color: #69AB1F; color: #fff; padding-top: 6px; padding-bottom:6px; margin-bottom:0px;">
            <a href="${ctx.host}/expiry-schedules?week=${week-1}&site=${site}" class="button button-link button-nav pull-left" style="text-decoration: none; color: #fff;">&nbsp;&nbsp;<span class="glyphicon glyphicon-chevron-left"></span>前一周</a>
            <fmt:formatDate value="${beginDate}" pattern="yyyy-MM-dd" />
            &nbsp;至&nbsp;
            <fmt:formatDate value="${endDate}" pattern="yyyy-MM-dd" />
            &nbsp;
            <c:if test="${not empty refer}">
              <c:if test="${not empty param.name or not empty param.mobile or not empty param.courseType}">
                “&nbsp;&nbsp;${param.name}&nbsp;&nbsp;${param.mobile}&nbsp;&nbsp;
                <c:if test="${param.courseType == 'individual'}">1V1</c:if>
                <c:if test="${param.courseType == 'year'}">年卡</c:if>
                &nbsp;&nbsp;”
              </c:if>
            </c:if>
            <c:if test="${week < 1}"> 
              &nbsp;&nbsp;<a href="${ctx.host}/expiry-schedules?week=${week+1}&site=${site}" class="button button-link button-nav pull-right" style="text-decoration: none; color: #fff;">后一周<span class="glyphicon glyphicon-chevron-right"></span>&nbsp;&nbsp;</a>
            </c:if>
          </p>
          <table class="table table-striped table-hover x-table" style="margin-bottom:20px; margin-top: 0px;">
            <thead>
              <tr>
                <th>日期&nbsp;-&nbsp;时间段</th>
                <th>学员名称</th>
                <th>学员手机</th>
                <th>教练&nbsp;/&nbsp;门店</th>
                <th>课程名称</th>
                <th>逾期次数</th>
                <th>取消次数</th>
                <th class="text-center">操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="schedule" items="${courseSchedules}" varStatus="loop">
                <tr>
                  <td><fmt:formatDate value="${schedule.occurDate}" pattern="yyyy-MM-dd"/>&nbsp;-&nbsp;${schedule.occurHour}</td>
                  <td>${schedule.student.name}</td>
                  <td>${schedule.student.mobile}
                  <td>${schedule.coach.name}&nbsp;/&nbsp;${schedule.site.name}</td>
                  <td>${schedule.course.name}</td>
                  <td>${userMonthCounts[loop.count-1] == null ? 0:userMonthCounts[loop.count-1].expireTimes}</td>
                  <td>${userMonthCounts[loop.count-1] == null ? 0:userMonthCounts[loop.count-1].cancelTimes}</td>                  
                  <td class="text-center">
                    <c:if test="${(schedule.courseType.individual or schedule.courseType.special or schedule.courseType.posture) && schedule.courseRound.courseStatus.ready}">
                      <a href="${ctx.host}/expiry-schedules/${schedule.id}/time" class="hover-no-text-decoration" data-toggle="modal" data-target="#expiry-schedule-time" title="重新排课" >重新排课</a>&nbsp;&nbsp;
                      <%-- <c:choose>
                        <c:when test="${courseRound.courseType.year}">
                          <c:if test="${currentPrincipal.admin || currentPrincipal.root}">
                            <a href="${ctx.host}/expiry-schedules/${schedule.id}/time" class="hover-no-text-decoration" data-toggle="modal" data-target="#expiry-schedule-time" title="重新排课">重新排课</a>&nbsp;&nbsp;
                          </c:if>
                        </c:when>
                        <c:otherwise>
                          <a href="${ctx.host}/expiry-schedules/${schedule.id}/time" class="hover-no-text-decoration" data-toggle="modal" data-target="#expiry-schedule-time" title="重新排课">重新排课</a>&nbsp;&nbsp;
                        </c:otherwise>
                      </c:choose> --%>
                    </c:if>
                    <c:if test="${schedule.courseType.year}">
                      <c:if test="${currentPrincipal.root || currentPrincipal.admin || currentPrincipal.areaServer || currentPrincipal.areaManager || currentPrincipal.siteManager || currentPrincipal.specialSite}">  
                        <a href="${ctx.host}/expiry-schedules/${schedule.id}/finished" class="hover-no-text-decoration" data-toggle="modal" data-target="#expiry-schedule-finish" title="已上课">已上课</a>
                      </c:if>
                    </c:if>
                    <c:if test="${(schedule.courseType.individual or schedule.courseType.special or schedule.courseType.posture)}">
                      <c:if test="${currentPrincipal.root || currentPrincipal.admin || currentPrincipal.areaServer || currentPrincipal.areaManager || currentPrincipal.siteManager || currentPrincipal.specialSite}">  
                        <a href="${ctx.host}/expiry-schedules/${schedule.id}/finished" class="hover-no-text-decoration" data-toggle="modal" data-target="#expiry-schedule-finish" title="已上课">已上课</a>
                       </c:if>
                    </c:if>
                  </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
          
        </div>

      </div>
    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/course/expiry-schedule-list.js">
    <script type="text/javascript">
      require(['page/course/expiry-schedule-list'], function(page) {
        page.init({
          week : '${week}'
        })
      })
    </script>
  </d:resource>
  
</body>

</html>